<template>
  <div class="cart-list">
    <!-- <li v-for="(item,index) in cartList" :key="index">{{item}}</li> -->
    <scroll class="content" ref="scroll">
      <!-- 把遍历到得item传进子组件展示出来 -->
      <cart-list-item v-for="(item,index) in cartList"
                      :product="item"
                      :key="index"/>
    </scroll>
  </div>
</template>

<script>
import Scroll from 'components/common/scroll/Scroll'
import CartListItem from './CartListItem'
import {mapGetters} from 'vuex'
export default {
  name:'CartList',
  components:{
    Scroll,
    CartListItem
  },
  computed:{
    ...mapGetters(['cartList'])
  },
  activated(){
    this.$refs.scroll.refresh()
  }
}
</script>

<style scoped>
  .cart-list{
    height: calc(100vh - 44px - 49px - 40px);
  }

  /* 使用scroll，必须给content一个高度 */
  .content{
    height: 100%;
    overflow: hidden;
  }
</style>
